﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using doppler.ws.ServiceReferenceAPIDoppler;
using System.Reflection;

namespace ConsoleApplication.TestDoppler
{
    class Program
    {
        static void Main(string[] args)
        {
            DopplerAPISoapClient webClient = new DopplerAPISoapClient();

            try
            {
                //webClient.
                
                //var suslist = webClient.GetSubscriberStatus(string.Empty, 0,string.Empty);
                
                
               
                
                ArrayOfCampaign campaignList = webClient.GetCampaignsList(string.Empty);

                if (campaignList != null)
                {
                    foreach (var campaignElement in campaignList)
                    {
                        ImprimirRespuesta(campaignElement);
                    }
                }
                else
                {
                    Console.WriteLine("GetCampaignsList devolvió nulo");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                webClient.Close();
            }

            Console.WriteLine("Pesione una tecla para continuar");
            Console.ReadKey();            
        }

        private static void ImprimirRespuesta(object respuesta)
        {
            Type respuestaType = respuesta.GetType();
            PropertyInfo[] properties = respuestaType.GetProperties();
            foreach (PropertyInfo property in properties)
            {
                object value = property.GetValue(respuesta, null);
                Console.WriteLine(string.Format("{0}: {1}", property.Name, value));
            }
        }
    }   
}
